<?php
if (!defined("MCTDESIGN")) die("# ");
$id = (int)$id;
global $anyDB,$temp,$dir_tpl, $shopurl;
include './_classes/mailer/senmail.php';
$temp->assign( 'base_tpl', "".$dir_tpl."" );
if ($act == 'lislichkh') {
    // get lis bài viêt phân trang 
    $pagegroup_size = 10;
    $page=_POST('p');
    if (!$page||$page==0){$page=1;}
    $limit=_POST('limit');
    if($limit==''||$limit>30) {$limit=30;}
    $offset=($page-1)*$limit;
    $li="limit $offset,$limit";    
    // dem tong ban gi 
    $sql ="select COUNT(t.tou_id) as tongbanghi  from ".$tb_fix."_tour as t left join ".$tb_fix."_tour_menu as c on t.tou_category = c.tme_id  where t.tou_calendar_act = 1";
    $query = $anyDB->query($sql);
    $ketqua  = $anyDB->getNext($query);
    $totalRecord = $ketqua['tongbanghi']; // tong so ban ghi
    //echo $totalRecord;
    // get du lieu 
    $sql = "select * from ".$tb_fix."_tour as t left join ".$tb_fix."_tour_menu as c on t.tou_category = c.tme_id  where t.tou_calendar_act = 1 ORDER BY tou_id DESC $li";
    $query = $anyDB->query($sql);
    $arr  = $anyDB->getAll($query);    
    foreach($arr as $key => $value){
        $arr[$key]['thoigian'] = date('d-m-Y',$value['tou_begin_time']);
        $arr[$key]['tentuor'] = convertText($value['tou_title']);
        $arr[$key]['tenchatour'] = convertText($value['tme_title']);
        $arr[$key]['cat_mota']  = subCutString($value['tou_des'],20);
        $arr[$key]['gia']  =  $value['tou_price'];
 
    }
    $temp->assign('datatour',$arr);
    $pages = pagenavigator($page,$totalRecord,$limit,$pagegroup_size,"LichKhoiHanh.html/");
    $temp->assign('pading',$pages);  
    $temp->assign('gtlichkh',get_data('shop_title_lichkh','config_values'));  
    $content = $temp->fetch( 'modules/_lichkhoihanh.mct' );
    
}
// get rour
if(!empty($_GET['idtour'])){
    $id = $_GET['idtour'];
    $sql = "select * from ".$tb_fix."_tour where tou_id = $id ";
    $q = $anyDB->query($sql);
    $arr = $anyDB->getNext($q);
    if ($arr['tou_price'] == 0){
        $gia = '';
    }else{
        $gia ="  Giá  :  ".$arr['tou_price'];
    }
    $html = "<input type='hidden' value='".$id."'  id='idtour' /> <b style='color:#008fd3'>".$arr['tou_title']."</b>".$gia." ";
    echo $html;
    exit();
}

if(!empty($_GET['sendmail'])){

    $id = $_GET['id'];
    $name = $_GET['name'];
    $email = $_GET['email'];
    $phone = $_GET['phone'];
    $ngaykh = $_GET['ngaykh'];
    $diachi = $_GET['diachi'];
    $quoctich = $_GET['quoctich'];
    $nguoilon = $_GET['nguoilon'];
    $treem = $_GET['treem'];
    $yeucauthem = $_GET['yeucauthem'];
    $sql = "select * from ".$tb_fix."_tour as t left join ".$tb_fix."_tour_menu as c on t.tou_category = c.tme_id   where t.tou_id = $id ";
    $q = $anyDB->query($sql);
    $arr = $anyDB->getNext($q);
    $link = "".get_data('shop_url','config_values')."Tours/".$arr['tme_root_id']."/".convertText($arr['tme_title'])."/".$arr['tme_id']."/".$arr['tou_id']."/".convertText($arr['tou_title'])."html";
	$subject = "Thông tin đặt tour  ";		
    $mess = "";
    $mess .= "<div style=\"width: 100%;height: 25px;background: green; text-align: center;color: #ffffff;\"> <span style='display: block;font-weight: bold;padding-top: 1px !important;' ><strong>Thông tin đặt tour  </strong></span></div>\n"; 
    $mess .= "<ul style=\"padding-left: 25px;position: relative;\">\n"; 
    $mess .= "    <li style=\"padding-top: 3px;\">Xin chào adminstrator: <strong> Có 1 khách hàng Đặt tuor tại web site http://postumtravel.vn thời gian gửi thông tin là ".date('d/m/Y - H:i:s')." </strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Họ tên: <strong> $name</strong></li>\n"; 
    $mess .= "    <li style=\"padding-top: 3px;\">Email : <strong> $email</strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Điện thoại: <strong> $phone</strong></li>\n"; 
    $mess .= "    <li style=\"padding-top: 3px;\">Địa chỉ: <strong> $diachi</strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Quốc tịch: <strong> $quoctich</strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Tên tour: <strong> <a href='$link' target='_blank' title='Click để xem chi tiết tour'> ".$arr['tou_title']." </a></strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Số người lớn: <strong> $nguoilon</strong></li>\n"; 
    $mess .= "    <li style=\"padding-top: 3px;\">Số trẻ em : <strong> $treem</strong></li>\n";
    $mess .= "    <li style=\"padding-top: 3px;\">Ngày muốn khởi hành:  <strong> $ngaykh</strong></li>\n";   
    $mess .= "    <li style=\"padding-top: 3px;\">Yêu cầu của khách hàng:  <strong> $yeucauthem</strong></li>\n";                           
    $mess .= "</ul>\n"; 
        
    $send = sendlienhe($subject,$mess);
    echo $send;
    
    exit();
}

